package com.example.controller;

import com.example.common.Result;
import com.example.exception.CustomException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public class WebController {
    @GetMapping("hello")
    public Result hello(){
        return Result.success("hello");
    }

    @GetMapping("/weather")
    public Result weather(){
        return Result.success("天气很好");
    }

    @GetMapping("/map")
    public Result map(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("name","青哥哥");
        map.put("age",18);
        return Result.success(map);
    }

    @GetMapping("/count")
    public Result count(){
        throw new CustomException("400", "错误请求");
    }
}
